"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.jwtkoa = exports.getToken = exports.path = exports.secret = void 0;
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
const koa_jwt_1 = __importDefault(require("koa-jwt"));
/**
 * jwt加密密钥
 */
const secret = "dgy@ggmqytwwdh%mmnyczyzttdg&nhhmwxnl(zl)";
exports.secret = secret;
/**
 * 数组中的路径不需要通过jwt验证
 */
const path = [/^\/api\/1.0\/login|\/api\/test/];
exports.path = path;
/**
 * 计算token值
 * @param userToken jwt明文部分json对象
 * @param time 有效期时间设定 1h
 */
const getToken = (userToken, time) => {
    return jsonwebtoken_1.default.sign(userToken, secret, { expiresIn: time });
};
exports.getToken = getToken;
const jwtkoa = koa_jwt_1.default({ secret: secret }).unless({
    path: path //数组中的路径不需要通过jwt验证
});
exports.jwtkoa = jwtkoa;
